<?php
/*------------------------------------------------------------------------
# resumes - company review paper management
# @author    pipapai.com
-------------------------------------------------------------------------*/

defined('_JEXEC') or die;
// disable core styles to avoid bs conflict
OC_Util::$core_styles = array();

if(isDevMode()) {
   OCP\Util::addStyle('resumes', 'resumes');
   OCP\Util::addStyle('calendar', 'calendar.common');
   OCP\Util::addScript('resumes', 'reviewpaper');
   OCP\Util::addScript('resumes', 'resumes.common');
} else {
   OCP\Util::addStyle('static', 'resumes');
   OCP\Util::addScript('static', 'apps/reviewpaper.min');
}

OCP\App::setActiveNavigationEntry('resumes_index');
// Load the questions
$questions = $_['questions'];
$basic_info = $_['basic_info'];
$correct_rate = $_['correct_rate'];
?>
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('resumes/js', 'resumes.php'));?>"></script>
<div class="hr_inner_navigate clearfix">
   <div class="hr_breadcrumbs">
      <?php echo($_['breadcrumb']); ?>
   </div>
</div>

<div class="hr_position_set hr_position_set_inner container" style="margin-top:50px;">
   <div class="container">
      <div class="row-fluid">
         <div class="span12">
            <div class="company_qes_fixed clearfix">
               <?=$basic_info->paper_title?>
               <span>（共<?=$basic_info->questioncount?>题 <?=$basic_info->totaltime?>分钟）</span>
               <br/>
               <span>提交时间: <?php echo JHtml::_('date',$basic_info->finished_date,'Y-m-d H:i');?>&nbsp;&nbsp;|&nbsp;</span>
               <span>用时: <?=$_['during_min']?>分钟&nbsp;&nbsp;|&nbsp;</span>
               <span>排名: <?=$_['testRank']?>/<?=$basic_info->num_applied?></span>
            </div>
         </div>
      </div>
   </div>

   <div class="row-fluid hr_oneconn_margin">
      <div class="span12 oneconn_box">
         <div class="lgrg_form">
            <?php if ($basic_info->is_reviewed == 1) : ?>
            <?php $bar_width= $basic_info->totalscore != 0 ? intval($correct_rate['total_correct_score'])/intval($basic_info->totalscore)*100 : 0;?>
            <div class="onlinetestscore large yahei">
               线上笔试得分：<span class="clearfix"><em class="orange" style="width:<?=$bar_width?>%;"></em></span><em style="color:#ff6600;"><?=$correct_rate['total_correct_score']?></em>/<?=$basic_info->totalscore?>
            </div>
            <?php endif;?>
            <?php if (count($questions) != $basic_info->questioncount) :?>
            <div class="test_actiontitle clearfix">
               <div class="t_act_one pull-left large yahei"><i></i>选择题</div>
               <div class="t_act_two pull-left">
                  正确率：<?=$correct_rate['singleanswer_correct_count']?>/<?=$correct_rate['singleanswer_total_count']?>
                  <span>|</span>
                  得分：<?=$correct_rate['singleanswer_score']?>/<?=$correct_rate['singleanswer_total_score']?>
               </div>
               <div class="t_act_three pull-right" id="show_all_single" data="{'jid': '<?=$basic_info->id?>','sid': '<?=$basic_info->sheetid?>'}">
                  <a href="javascript:;">查看全部</a><i></i>
               </div>
               <?php if ($correct_rate['singleanswer_correct_count'] != $correct_rate['singleanswer_total_count'] ) : ?>
               <div class="t_act_four pull-right" id="show_wrong_single" data="{'jid': '<?=$basic_info->id?>','sid': '<?=$basic_info->sheetid?>'}">
                  <a href="javascript:;">查看错题</a><i></i>
               </div>
               <?php endif;?>
            </div>

            <div id="select_questionsbox" style="display:none;"></div>

            <?php endif;?>

            <?php if (!empty($questions)) : ?>
            <div class="test_actiontitle clearfix">
               <div class="t_act_one t_subjective pull-left large yahei"><i></i>主观题</div>
               <?php if ($basic_info->is_reviewed == 1) : ?>
               <div class="t_act_two pull-left">
                  得分：<?=$correct_rate['freeinput_score']?>/<?=$correct_rate['freeinput_total_score']?>
               </div>
               <div class="t_act_three pull-right" id="show_freeinput">
                  <a href="javascript:;">查看全部</a><i></i>
               </div>
               <?php else: ?>
               <div class="t_act_two pull-left">
                  共<?=count($questions)?>题
                  <em style="color:#ff0000;">(尚未打分)</em>
               </div>
               <?php endif;?>
            </div>
            <?php if ($basic_info->is_reviewed == 1) : ?>
            <div id="subjective_questionbox" style="display:none;">
               <?php foreach ($questions as $k => $question) :?>
               <?php $answer = json_decode($question->answer);?>
               <div class="test_questionbox">
                  <h6>
                     <?=$k+1?>.<?=$question->question?>
                     <span><?="（".$question->score."分）"?></span>
                     <span class="red">（得分：<?=$question->user_score?>）</span>
                  </h6>
                  <div class="text_giveanswer">
                     参考答案：<?php echo $answer[0] ? $answer[0] : "暂无"?>
                  </div>
                  <div class="test_question_select test_jobseekeranswer normal">
                     <?php echo $question->user_answer ? $question->user_answer : "未填写"?>
                  </div>
               </div>
            <?php endforeach;?>
            </div>
            <?php else: ?>
            <form action="<?php echo OC_Helper::linkToRoute("resume_postscore");?>" method="post" name="review_paper_form" id="review_paper_form">
            <div id="subjective_questionbox">
               <?php foreach ($questions as $k => $question) :?>
               <?php $answer = json_decode($question->answer);?>
               <div class="test_questionbox">
                  <h6>
                     <?=$k+1?>.<?=$question->question?>
                     <span>
                        <?="（".$question->score."分）"?>
                        <?php if($_['adminuser']): ?>
                        <input type="text" name="<?=$question->question_id?>" value="<?php echo strlen(trim($question->user_answer)) > 0 ? "" : "0"?>" class="{required:true,digits:true,max:<?=$question->score?>,messages:{max:'打分超过了题目分值！'}}" style="width:40px;"/>
                        <em>打分：</em>
                        <?php endif; ?>
                     </span>
                  </h6>
                  <div class="text_giveanswer">
                     参考答案：<?php echo $answer[0] ? "<pre>".$answer[0]."</pre>" : "暂无"?>
                  </div>
                  <div class="test_question_select test_jobseekeranswer normal">
                     <?php echo strlen(trim($question->user_answer)) > 0 ? "<pre>".trim($question->user_answer)."</pre>" : "求职者未作答"?>
                  </div>
               </div>
            <?php endforeach;?>
            </div>

            <div class="ready_btn ready_btn_top">
               <?php if($_['adminuser']): ?>
               <button id="reviewSubmitbtn" class="ppp_bluebtn ready_btn_width" style="margin:auto;">提交打分</button>
               <input type="hidden" name="jobid" value="<?=$basic_info->jobid?>"/>
               <input type="hidden" name="jobseeker_id" value="<?=$basic_info->id?>"/>
               <input type="hidden" name="sheetid" value="<?=$basic_info->sheetid?>"/>
               <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
               <div id='errormsg' class='error' style='color:red; margin:auto; display:none; text-align:center;'></div>
               <?php endif; ?>
            </div>
            </form>
            <?php endif;?>
            <?php endif;?>

         </div>
      </div>
   </div>
</div>